Assignemnt #55 and 53 program
Code
///Name: Derrick Andreasen
///Period: 7
///Program name: 53rd Program
///File name: FiftProg.java
///Date Finished:11/5/2015
import java.util.Random;
import java.util.Scanner;
public class FiftProg
{
public static void main( String[] args )
{
Scanner keyboard= new Scanner(System.in);
Random r = new Random();
int guess, x = 1 + r.nextInt(10);
System.out.println( "I'm thinking of a number from 1 to 10." );
System.out.println( "" );
System.out.print( "Your guess: " );
guess = keyboard.nextInt();
System.out.println( "" );
if(guess == x)
{
System.out.println( "That's right! My secret number was " + x );
}
else if(guess <= x)
{
System.out.println( "Sorry, but I was really thinking of " + x );
}
else if(guess >= x)
{
System.out.println( "Sorry, but I was really thinking of " + x );
}
System.out.println( "" );
}
}
Picture of the output